package eu.jpereira.trainings.designpatterns.structural.facade.facade;

import eu.jpereira.trainings.designpatterns.structural.facade.BookstoreFacade;
import eu.jpereira.trainings.designpatterns.structural.facade.model.Book;
import eu.jpereira.trainings.designpatterns.structural.facade.model.Customer;
import eu.jpereira.trainings.designpatterns.structural.facade.model.DispatchReceipt;
import eu.jpereira.trainings.designpatterns.structural.facade.model.Order;
import eu.jpereira.trainings.designpatterns.structural.facade.service.BookDBService;
import eu.jpereira.trainings.designpatterns.structural.facade.service.CustomerDBService;
import eu.jpereira.trainings.designpatterns.structural.facade.service.CustomerNotificationService;
import eu.jpereira.trainings.designpatterns.structural.facade.service.OrderingService;
import eu.jpereira.trainings.designpatterns.structural.facade.service.WharehouseService;

public class DefaultBookstoreFacade implements BookstoreFacade
{
	WharehouseService warehouseService;
	OrderingService orderingService;
	BookDBService bookService;
	CustomerDBService customerService;
	CustomerNotificationService customerNotificationService;
	
	Book book;
	Customer customer;
	Order order;
	DispatchReceipt dispatchReceipt;
	@Override
	public void placeOrder(String customerId, String isbn) 
	{
		// TODO Auto-generated method stub
		customer = customerService.findCustomerById(customerId);
		book = bookService.findBookByISBN(isbn);
		order = orderingService.createOrder(customer,book);
		dispatchReceipt = warehouseService.dispatch(order);
		customerNotificationService.notifyClient(dispatchReceipt);
	}
		
	public void setWarehouseService(WharehouseService service)
	{
		this.warehouseService = service;
	}
	public void setOrderingService(OrderingService service)
	{
		this.orderingService = service;
	}
	public void setBookService(BookDBService service)
	{
		this.bookService = service;
	}
	public void setCustomerService(CustomerDBService service)
	{
		this.customerService = service;
	}
	public void setCustomerNotificationService(CustomerNotificationService service)
	{
		this.customerNotificationService = service;
	}
}
